﻿/*
 *	Copyright (c) 2009 Queensland University of Technology. All rights reserved.
 *	The QUT Bioinformatics Collection is open source software released under the 
 *	Microsoft Public License (Ms-PL): http://www.microsoft.com/opensource/licenses.mspx.
 */
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace QUT.Bio.Util {
	/// <summary>
	/// A popup window with an embedded twirly thing.
	/// </summary>
	
	public class SimpleProgressWindow: PopupWindow {
		private TwirlyThing twirlyThing = new TwirlyThing();

		public SimpleProgressWindow ( string title ) {
			Title = title;

			ClientArea.North = new Grid() {
				Height = 10,
				MinHeight = 10,
				MinWidth = 10
			};

			ClientArea.South = new Grid() {
				Height = 10,
				MinHeight = 10,
				MinWidth = 10
			};

			ClientArea.Centre = twirlyThing;

			WindowChanged += WindowChanging;
		}

		public TwirlyThing TwirlyThing {
			get {
				return twirlyThing;
			}
		}

		void WindowChanging ( PopupWindow source, WindowChangeEventType eventType ) {
			SimpleProgressWindow w = (SimpleProgressWindow) source;

			if ( eventType==WindowChangeEventType.WindowShown ) {
				twirlyThing.Start();
			}
			else if ( eventType==WindowChangeEventType.WindowHidden ) {
				twirlyThing.Stop();
			}
		}
	}
}
